package com.example.skindemo;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.app.SkinAppCompatDelegateImpl;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import skin.support.SkinCompatManager;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView change=findViewById(R.id.change);
        TextView restore=findViewById(R.id.restore);
        change.setOnClickListener(this);
        restore.setOnClickListener(this);
    }

    @NonNull
    @Override
    public AppCompatDelegate getDelegate() {
        return SkinAppCompatDelegateImpl.get(this, this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.restore:
                // 恢复应用默认皮肤
                SkinCompatManager.getInstance().restoreDefaultTheme();
                break;
            case R.id.change:
                SkinCompatManager.getInstance().loadSkin("yellow", SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN); // 后缀加载
                break;
            default:
                break;
        }
    }
}